from django.db import models
from datetime import datetime
from userapp.models import PayOrderModel

# Create your models here.


# 骑手user表
class RiderModel(models.Model):
    r_name = models.CharField(max_length=32, verbose_name="用户名", unique=True)
    mobile = models.CharField(max_length=16, verbose_name="手机号", unique=True)
    img = models.CharField(max_length=256, verbose_name="头像")
    login_time = models.DateTimeField(default=datetime.now, verbose_name="登录时间")
    reg_time = models.DateTimeField(default=datetime.now, verbose_name="注册时间")
    intro = models.CharField(max_length=256, default="这个人懒，什么也没写", verbose_name="用户简介")
    status = models.CharField(max_length=32, verbose_name="是否上线")

    def __str__(self):
        return self.r_name

    class Meta:
        db_table = 'rider_model'


# 抢单大厅
class OrderLobbyModel(models.Model):
    o_id = models.ForeignKey(to=PayOrderModel,on_delete=models.CASCADE,verbose_name='订单ID')
    status = models.CharField(max_length=16,default=0,verbose_name='0 待抢单，1 已抢单')

    def __str__(self):
        return self.status

    class Meta:
        db_table = 'order_lobby_model'


# 骑手订单表
class RiderOrderModel(models.Model):
    order_id = models.ForeignKey(to=OrderLobbyModel,on_delete=models.CASCADE,verbose_name='订单ID')
    status = models.CharField(max_length=16,default=0,verbose_name='0 接单 1 完成订单 2 转让订单')

    def __str__(self):
        return self.status

    class Meta:
        db_table = 'rider_order_model'

